package io.bluerain.bocket.message;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;

/**
 * Created by foredawn on 15-8-15.
 * 数据消息
 */
public class DataMessage extends Message {

    private InputStream inputStream;
    private InputStreamReader inputStreamReader;

    public DataMessage(InputStream inputStream, Charset charset) {
        this.inputStream = inputStream;
        this.charset = charset;
        inputStreamReader = new InputStreamReader(inputStream, charset);
    }

    public InputStream getInputStream() {
        return inputStream;
    }

    public InputStreamReader getInputStreamReader() {
        return inputStreamReader;
    }

    public void close() {
        try {
            if (inputStream != null)
                inputStream.close();
            if (inputStreamReader != null)
                inputStreamReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
